package org.example.aop.config;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Slf4j
@Aspect
@Component
public class TestAspect {
    @Before("execution(* org.example.aop.controller.*.*(..))")
    public void doBefore() {
        System.out.println("doBefore");
    }

    @After("execution(* org.example.aop.controller.*.*(..))")
    public void doAfter() {
        System.out.println("doAfter");
    }

    @AfterReturning("execution(* org.example.aop.controller.*.*(..))")
    public void doAfterReturning() {
        System.out.println("doAfterReturning");
    }

    @AfterThrowing("execution(* org.example.aop.controller.*.*(..))")
    public void doAfterThrowing() {
        System.out.println("doAfterThrowing");
    }
    @Around("execution(* org.example.aop.controller.*.*(..))")
    public Object testAround(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("around执行前");
        Object ret = joinPoint.proceed();
        System.out.println("around执行后");
        System.out.println("around" + ret);
        return "around" + ret;
    }
}
